<%
var headerPart = {
%>
<style>
	html{background-color: #fff!important;}
</style>
<% }; %>
<% layout("/layouts/micro.html",{headerSection:headerPart}){ %>
<div class="childrenBody">
    <div class="layui-tab-content">
        <form id="inputForm" action="${ctx}/sys/user/save" method="post" class="layui-form">
            <input type="hidden" name="id" value="${user.id}"/>
            <#message content="${message!}"/>
            <div class="layui-form-item">
		    <label class="layui-form-label">头像</label>
		    <div class="layui-input-block">
				<input type="hidden" id="nameImage" name="photo" value="${user.photo}" class="input-xlarge"/>
				<#ckfinder input="nameImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100" readonly="false"/>
		    </div>
		  </div>	
		<div class="layui-row layui-col-space15 layui-form-item">
			<div class="layui-col-md6">
				<label class="layui-form-label">归属公司:</label>
				<div class="layui-input-block">
					<#treeselect id="company" name="company.id" value="${user.company.id}" labelName="company.name" labelValue="${user.company.name}"
									title="公司" url="/sys/office/treeData?type=1" cssClass="required" allowInput="false"/>
				</div>
			</div>
			
			<div class="layui-col-md6">
				<label class="layui-form-label">归属部门:</label>
				<div class="layui-input-block">
					<#treeselect id="office" name="office.id" value="${user.office.id}" labelName="office.name" labelValue="${user.office.name}"
									title="部门" url="/sys/office/treeData?type=2" cssClass="required" notAllowSelectParent="true"/>
				</div>
			</div>
		</div>
		
		<div class="layui-row layui-col-space10 layui-form-item">
           <div class="layui-col-md4">
				<label class="layui-form-label">工号:</label>
				<div class="layui-input-block">
					<input type="text" name="no" value="${user.no}" class="layui-input" lay-verify="required"/>
				</div>
			</div>
			<div class="layui-col-md4">
				<label class="layui-form-label">姓名:</label>
				<div class="layui-input-block">
					<input type="text" name="name" value="${user.name}"  class="layui-input" lay-verify="required"/>
				</div>
			</div>
			<div class="layui-col-md4">
				<label class="layui-form-label">登录名:</label>
				<div class="layui-input-block">
					<input id="oldLoginName" name="oldLoginName" type="hidden" value="${user.loginName}" class="layui-input layui-disabled" >
					<input  type="text" name="loginName" value="${user.loginName}"  class="layui-input" lay-verify="required"/>
				</div>
			</div>
		</div>
		
		<div class="layui-row layui-col-space10 layui-form-item">
			<div class="layui-col-md4">
				<label class="layui-form-label">邮箱:</label>
				<div class="layui-input-block">
					<input type="email" name="email"  maxlength="100" class="layui-input"/>
				</div>
			</div>
			<div class="layui-col-md4">
				<label class="layui-form-label">密码:</label>
				<div class="layui-input-block">
					<input id="newPassword" name="newPassword" type="password" value="" maxlength="50" class="layui-input" />
				<%if(isNotEmpty(user.id)){%><span class="help-inline">若不修改密码，请留空。</span><%}%>
				</div>
			</div>
			<div class="layui-col-md4">
				<label class="layui-form-label">确认密码:</label>
				<div class="layui-input-block">
					<input id="confirmNewPassword" name="confirmNewPassword" type="password" value="" maxlength="50" class="layui-input" />
				</div>
			</div>
		</div>
		<div class="layui-row layui-col-space10 layui-form-item">
			<div class="layui-col-md4">
				<label class="layui-form-label">电话:</label>
				<div class="layui-input-block">
					<input type="text" name="phone" value="${user.phone}" class="layui-input"/>
				</div>
			</div>
			<div class="layui-col-md4">
				<label class="layui-form-label">手机:</label>
				<div class="layui-input-block">
					<input  type="text" name="mobile" value="${user.mobile}"  class="layui-input"/>
				</div>
			</div>
		</div>
		<div class="layui-row layui-col-space15 layui-form-item">
			<div class="layui-col-md6">
				<label class="layui-form-label">用户类型:</label>
				<div class="layui-input-inline">
					<select name="userType" class="input-xlarge" required="true">
						<option value="" label="请选择"/>
						<#options items = "${@DictUtils.getDictList('sys_user_type')}" value="${user.userType}"/>
					</select>
				</div>
			</div>
			<div class="layui-col-md6">
				<label class="layui-form-label">允许登录:</label>
				<div class="layui-input-inline">
					<#radio name="loginFlag" items = "${@DictUtils.getDictList('yes_no')}" value="${user.loginFlag}"/>
				</div>
			</div>
		</div>	
		<div class="layui-form-item">
			<label class="layui-form-label">用户角色：</label>
			<div class="layui-input-block">
				<%for(role in allRoles){%>
				<input type="checkbox" name="roleIdList" title="${role.name}" lay-skin="primary" value="${role.id}" <%if(array.contain(user.roleIdList,role.id)){%>checked<%}%>/>
				<%}%>
			</div>
		</div>
		<%if(isNotEmpty(user.id)){%>
		<div class="layui-row layui-col-space15 layui-form-item">
			<div class="layui-col-md6">
				<label class="layui-form-label">创建时间:</label>
				<div class="layui-input-block">
					<div class="layui-form-mid">${user.createDate,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
				</div>
			</div>
			<div class="layui-col-md6">
				<label class="layui-form-label">最后登录:</label>
				<div class="layui-input-block">
					<div class="layui-form-mid">IP: ${user.loginIp}&nbsp;&nbsp;&nbsp;&nbsp;时间：${user.loginDate,dateFormat="yyyy-MM-dd HH:mm:ss"}</div>
				</div>
			</div>
		</div>
		<%}%>
        <div class="layui-form-item layui-hide">
		    <div class="layui-input-block">
		      <button class="layui-btn" lay-filter="userForm" id="userForm" lay-submit>保 存</button>
		      <button type="reset" class="layui-btn layui-btn-primary" onclick="history.go(-1)">返回</button>
		    </div>
	  	</div>
        </form>
     </div>
</div>
<script>
    layui.use(['form','laydate'], function(){
        var form = layui.form,laydate = layui.laydate;
        form.render();
    });
</script>
<%}%>